home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / mnp_c.zip / MNPDAT.H < prev    next >
C/C++ Source or Header  |  1990-05-16  |  8KB  |  218 lines

  1. /***************************************************************************
  2.  
  3.                  General MNP Definitions
  4.  
  5.     2/4/88 - RBUF_LEN changed for Class 4,
  6.             lcb.class4 added
  7.     8/27/87 - RBUF_LEN increased to 576..gp
  8.     10/29/87 - explict data typing..gp
  9.  
  10. ***************************************************************************/
  11.  
  12. /* Data Types 
  13. */
  14. #define SIGN_8 signed char
  15. #define USIGN_8 unsigned char
  16. #define SIGN_16 signed short int
  17. #define USIGN_16 unsigned short int
  18.  
  19. #define SUCCESS     0    /* success return code from all functions */
  20. #define TRUE        1
  21. #define FALSE        0
  22.  
  23. /*-------------------- Return Codes used by LLVL -------------------------*/
  24.  
  25. #define FAILURE      (-64)    /* no further information */
  26. #define TIME_OUT     (-65)    /* timeout */
  27. #define NO_PHYSICAL  (-66)    /* physical connection down */
  28. #define LNK_DOWN     (-67)    /* link connection down */
  29.                 /* see mnp_cb.ld_reason for LD reason code */
  30. #define LR_CODE      (-73)    /* when there is an error in parsing an LR,
  31.                    an LD is sent back with reason code (1-5)
  32.                    LR_CODE is added to that reason code and
  33.                    returned as one of the 5 error codes below
  34.  
  35.               -72    received LPDU not LR as expected
  36.               -71    reserved
  37.               -70    incompatible or unknown parameters
  38.               -69    reserved
  39.               -68    reserved
  40.                 */
  41.  
  42. #define BUFF_ERR     (-75)    /* buffer error */
  43.  
  44. /* -----------------------------------------------------------------------*/
  45.  
  46. #define NULL        0
  47.  
  48. /* Protocol Data Units */
  49.  
  50. #define LR        1
  51. #define LD        2
  52. #define LT        4
  53. #define LA        5
  54. #define LN        6
  55. #define LNA        7
  56.  
  57. /* Protocol Data Units Formats (Offsets) */
  58.  
  59. #define PDU_LI        0        /* header length indicator */
  60. #define PDU_TYPE    1        /* type of pdu */
  61.  
  62. struct TIMERS {
  63.     USIGN_16 g;
  64.     USIGN_16 ack;
  65.     USIGN_16 fcw;
  66.     USIGN_16 lr;
  67.     USIGN_16 lt;
  68.     USIGN_16 ln;
  69.     };
  70.  
  71.  
  72. /***************************************************************************
  73. *                                       *
  74. *            Buffer Management Definitions               *
  75. *                                       *
  76. ***************************************************************************/
  77.  
  78.  
  79. /* each blst (buffer list) structure controls an actual buffer */
  80.  
  81. struct BLST {
  82.     USIGN_16 mark;            /* 0: free | 1: used */
  83.     USIGN_8 *bptr;            /* pointer to the actual buffer */
  84.     USIGN_16 len;            /* lenght of data in buffer */
  85.     struct BLST *next_b;        /* pointer to next structure */
  86. };
  87.  
  88. /* each buffer structure controls a linked list of blst structures */
  89.  
  90. struct BUFFER {
  91.     struct BLST *list;        /* pointer to head node */
  92.     struct BLST *free;        /* pointer to node with free buffer */
  93.     USIGN_16 num;            /* total number of nodes (buffers) */
  94.     USIGN_16 used;            /* number of buffers being used */
  95.     struct BLST *used_lst;        /* pointer to head of list
  96.                       of buffers in use */
  97.     struct BLST *next_lst;
  98. };
  99.  
  100. #define BIT0_ON     (0x01)
  101.  
  102. /***************************************************************************
  103.  
  104.                      LLVL Definitions
  105.  
  106. ***************************************************************************/
  107.  
  108. /* Link Disconnect reason code */
  109. #define PROT_ERR        1
  110. #define PROT_LVL_MISMATCH    2
  111. #define BAD_LR_PARMS        3
  112. #define RETRAN_TMR_EXP        4
  113. #define INACT_TMR_EXP        5
  114.  
  115. struct link_ctl_blk {
  116.     /* variables initialized at one-time initialization */
  117.     USIGN_8 status_1;        /* link status */
  118.     USIGN_8 status_2;        /* link status */
  119.     USIGN_8 status_3;        /* link status */
  120.     USIGN_16 ack_timer;        /* acknowledgement timer value */
  121.     USIGN_16 max_data_sz;    /* negotiated maximum user data size */
  122.     USIGN_16 prot_level;     /* negotiated protocol level */
  123.     USIGN_16 lt_tmr;        /* lt (data) retransmission timer value */
  124.     USIGN_16 srv_class;        /* local service class */
  125.     USIGN_16 window_sz;        /* negotiated window size */
  126.     USIGN_16 window_tmr;     /* flow control window timer value */
  127.     USIGN_8 baud_rate;        /* current link baud rate */
  128.     USIGN_8 ln_rsn;        /* last ln (remote) receive sequence number */
  129.     USIGN_8 ln_ssn;        /* last ln (local) send sequence number */
  130.     USIGN_16 class4;        /* MNP Class 4 operation enabled if TRUE */
  131.  
  132.     /* variables initialized/reset at link reset */
  133.     USIGN_8 ltssn_acked;    /* last lt sent seq. # that has been acked */
  134.                         /* by remote link */
  135.     USIGN_8 ltrsn_acked;    /* last lt received seq. # that has been */
  136.                 /* acked by local link */
  137.     USIGN_8 lt_rsn;        /* last lt (remote) received sequence number */
  138.     USIGN_8 lt_ssn;        /* last lt (local) sent sequence number */
  139.     USIGN_16 ln_ret_cnt;     /* ln retransmission count */
  140.     USIGN_16 lt_ret_cnt;     /* lt retransmission count */
  141.  
  142.     /* variables initialized at start of data phase */
  143.     USIGN_16 ack_threshold;    /* acknowledgement threshold */
  144.     USIGN_16 lcl_credit;     /* receive (local) credit */
  145.     USIGN_16 rem_credit;     /* send (remote) credit */
  146.  
  147.     /* other variables */
  148.     USIGN_16 l_disc_code;    /* link layer disconnect code */
  149.     USIGN_16 ln_rtype;        /* ln lpdu type received */
  150.     USIGN_16 ln_stype;        /* ln lpdu type to be sent */
  151.     USIGN_16 lpdu_type;        /* type of last lpdu received */
  152.     USIGN_16 u_disc_code;    /* user disconnect code */
  153.     USIGN_8 lr_parm;        /* lr parameter flag */
  154. };
  155.  
  156. /* Link Status Byte 1 bit definition (lcb.status_1)
  157. */
  158. #define LA_RECEIVED    1    /* on: la lpdu received */
  159. #define LINK_EST    2    /* on: link established */
  160. #define DATA_READY    4    /* on: user data available (lt received) */
  161. #define ACK_TIMER    8    /* on: timer set */
  162. #define RET_TIMER    16    /* on: retran timer set */
  163. #define MODE        32    /* on: acceptor ║ off: initiator */
  164. #define HDUPLEX     64    /* on: half duplex ║ off: full duplex */
  165. #define ACK        128    /* on: ack needed - normal ack sequence */
  166.  
  167. /* Link Status Byte 2 bit definition (lcb.status_2)
  168. */
  169. #define FORCE_ACK    1    /* on: force ack needed - lt received bad */
  170. #define FORCE_RET    2    /* on: lt retran needed - la received bad */
  171. #define ZERO_WNDW    4    /* on: zero window in effect */
  172. #define WNDW_TIMER    8    /* on: flow control window timer set */
  173.  
  174. /* Link Status Byte 3 bit definition (lcb.status_3)
  175. */
  176. #define LN_RECEIVED    1    /* on: ln lpdu received */
  177. #define LNA_RECEIVED    2    /* on: lna lpdu received */
  178. #define FORCE_LNA    4    /* on: need to send an lna lpdu */
  179. #define LN_TIMER    16    /* on: ln retran timer set */
  180. #define DUP_IGNORED    32    /* on: received an immediate duplicate LT */
  181.                 /*     it was ignored */
  182. #define LN_SENT    64    /* on: ln lpdu sent, not acked */
  183.  
  184. /* timer event flag definition */
  185. #define FRAME_SND    1    /* frame has been sent */
  186. #define FRAME_RCV    2    /* a frame has been received */
  187. #define FRAME_DN    3    /* frame sent, including end flag */
  188.  
  189. /* offsets of LPDU */
  190. #define LT_SEQ        4    /* sequence number in LT */
  191.  
  192. /* Link buffer size definitions */
  193. #define RBUF_LEN    2304            /* 9 x 256 (Class 4 max) */
  194. #define SBUF_LEN    1024
  195.  
  196. /***************************************************************************
  197. *                                       *
  198. *            MNP Control Block Definitions               *
  199. *                                       *
  200. ***************************************************************************/
  201.  
  202. struct MNP_CB {
  203.     SIGN_16 (*l_connect)();    /* function to establish a link connection */
  204.     SIGN_16 (*l_disconnect)();    /* function to disconnect a link connection */
  205.     SIGN_16 (*l_link)();    /* function to maintain link */
  206.     SIGN_16 (*lt_send)();    /* function to send an lt lpdu */
  207.     SIGN_16 (*lt_receive)();    /* function to receive an lt lpdu */
  208.     SIGN_16 (*l_update)();    /* function to change link variables */
  209.     SIGN_16 (*ret_rcvbuf)();    /* function to return a receive buffer */
  210.     struct BUFFER *rb;    /* addr of struct to control receive buffers */
  211.     struct BUFFER *ftb;    /* addr of struct to control transmit buffers */
  212.     struct BUFFER *rlkb;    /* addr of struct to control lnk rec buffers */
  213.     struct BUFFER *lkb;    /* addr of struct to control lnk xmit buffers */
  214.     SIGN_16 ld_reason;        /* reason code in the received LD */
  215.     USIGN_16 ld_source;        /* disc source: 0=layer, 1=user */
  216.     USIGN_16 parity;        /* parity type */
  217. };
  218.